const http = require("http");
const fs = require('fs');
// const { json } = require("stream/consumers");
const server = http.createServer((req, res) => {
    // 解决中文乱码问题
    res.setHeader("content-type", "text/html; charset=utf-8");
    // 解决跨域问题
    res.setHeader("Access-Control-Allow-Origin", "*")
    // 接受自定义请求头
    res.setHeader("Access-Control-Allow-Headers", "*");
    console.log(res);
    res.body = res;
    res.write(JSON.stringify(res));
    res.end();
});

server.listen(8080,()=>{
    console.log("服务器已开启,端口8080");
});